package com.test.jms.topic;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
		@ActivationConfigProperty(propertyName = "destination", propertyValue = ReportSubscriberMDB.TOPIC_REPORT_TOPIC),
		@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class ReportSubscriberMDB implements MessageListener {
	// public static final String CONNECTION_FACTORY = "ConnectionFactory";
	public static final String TOPIC_REPORT_TOPIC = "topic/reportTopic";

	@Override
	public void onMessage(Message msg) {
		TextMessage tm = (TextMessage) msg;
		try {
			System.out.println("ReportSubscriberMDB got a message: " + tm.getText());
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}

}
